<%-- 
    Document   : CMS_rating
    Created on : Nov 24, 2013, 3:38:22 PM
    Author     : BibooChung
--%>


<!DOCTYPE html>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import = "java.util.*" import="cart.hibernate.rating.*" import="cart.*,java.net.*,java.text.*" %>
<jsp:useBean id = "manager" scope= "request" class = "cart.hibernate.rating.ManageRating" />

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Manage Rating</h1>

        <!-- Table with integrated management -->
        <table border="2" style="border-color:black;margin-bottom:20px;">
                <tr>
                    <th>Movie ID</th>
                    <th>Average rate</th>
                    <th>Number of rate</th>
                    <th>Update?</th>
                    <th>Delete?</th>
                </tr>
                <%
                    List ratingList = manager.getAllRating();
                    Iterator iter = ratingList.iterator();

                    while (iter.hasNext())
                    {

                        Rating rating = (Rating) iter.next();
                %>
                        <tr>
                            <form action="ManageRatingServlet" method="post">
                                <input type="hidden" name="ratingId" value="<%= rating.getMovieId() %>">
                                <td>
                                    <%= rating.getMovieId() %>
                                </td>
                                <td>
                                    <input type="text" name="avgRate" value="<%= rating.getAvgRate() %>" />
                                </td>
                                <td>
                                    <input type="text" name="numOfRate" value="<%= rating.getNumOfRate() %>" />  
                                </td>
                                <td>
                                    <input type="submit" name="submit" value="update">         
                                </td>
                                <td>
                                    <input type="submit" name="submit" value="delete">
                                </td>
                            </form>
                        </tr>
                <%        
                    }
                %>
                    <tr>
                        <form action="ManageRatingServlet" method="post">
                            <td><b>Should not be used</b> Enter new rating : </td>
                            <td><input type="text" name="avgRate" id="avgRate" /></td>
                            <td><input type="text" name="numOfRate" id="numOfRate" /></td>
                            <td><input type="submit" name="submit" value="add"></td>
                        </form>
                    </tr>
        </table>


    </body>
</html>

